#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Mikan iCal ビュー 機能

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_7"
__date__    = "2013/02/24"
__license__ = 'LGPL'

# ------------------------------------------------------------
## インポート
# ------------------------------------------------------------
# Python

# ESiPC
from esipc import ESiPCProperty

# Mikan
from mikan.view import MikanTextView
from mikan.core import MIKAN_HTTP_HEADER

# ------------------------------------------------------------
## 変数
# ------------------------------------------------------------

# ------------------------------------------------------------
## 関数
# ------------------------------------------------------------

class MikaniCalView(MikanTextView):
	def __init__(self, r, filename, cal):
		self.FCal = cal
		self.FFileName = filename

		super(MikaniCalView, self).__init__(r)

	def set_cal(self):
		return self.FCal

	def get_cal(self):
		return self.FCal

	def get_filename(self):
		return self.FFileName

	def set_filename(self, value):
		self.FFileName = value

	def get_content_type(self):
		return "text/calendar; charset=" + self.encode

	def get_content(self):
		return self.cal.to_ical()

	def perform(self):
		# HTTPヘッダーに設定
		self.request.headers[MIKAN_HTTP_HEADER.NAME_CONTENT_DISPOSITION] = MIKAN_HTTP_HEADER.VALUE_CONTENT_DISPOSITION % (self.filename)

		return True

	# ----------------------------------------------------
	## Property
	filename = ESiPCProperty(get_filename, set_filename, None)
	cal = ESiPCProperty(get_cal, set_cal, None)

# ------------------------------------------------------------
## クラス
# ------------------------------------------------------------

# ------------------------------------------------------------
## メイン関数
# ------------------------------------------------------------
## メイン処理
if __name__ == '__main__':
	pass

# ------------------------------------------------------------
